import {UPLOAD_File_URL} from '@/config/index.js'
// 上传文件

const upload = (tempFilePaths)=>{
	return new Promise((reslove,reject)=>{
		uni.showLoading({
			title:'上传中...'
		})
		uni.uploadFile({
			url: UPLOAD_File_URL, //仅为示例，非真实的接口地址
			header: {
			    Authorization : uni.getStorageSync("token") //自定义请求头信息
			},
			filePath: tempFilePaths,
			name: 'file',
			formData: {
				'user': 'test'
			},
			success: (uploadFileRes) => {
				// console.log(uploadFileRes.data);
				uni.hideLoading()
				reslove(JSON.parse(uploadFileRes.data))
			},
			fail(error){
				uni.hideLoading()
				reject(error)
			}
		});
	})
}

export default {
	upload
}